package com.mao.referencetest;

public class TestJavaMethodReference {




    public static void main(String[] args) {
        Book book = new Book();
        book.setAuthor("Author");
        book.setName("Hello World");
        book.setPage(1);
        System.out.println(book.hashCode()); //460141958
        System.out.println(book.getName().hashCode()); //-862545276
        notifyBookName(book);
        System.out.println(book.hashCode()); //460141958
        System.out.println(book.getName().hashCode()); //69609650


        int a = 1000, b = 2;
        int sum = sum(a,b);
        System.out.println(String.valueOf(sum));//1002
        updateAValue(a);
        System.out.println(a);//1000
        sum=sum(a,b);
        System.out.println(String.valueOf(sum));//1002


         Integer aI;
        aI = new Integer(1000);
        System.out.println(aI.hashCode()); //1000
        updateAInteger(aI);
        System.out.println(aI.hashCode()); //1000


        String str = new String("Hello World");
        updateStrValue(str);



    }

    private static void updateStrValue(String str) {
        str = "123456";
    }

    private static void updateAInteger(Integer aI) {
        System.out.println("方法内 前："+aI.hashCode()); //1000
        aI =  new Integer(1001);
        System.out.println("方法内 后："+aI.hashCode()); //1001
    }

    private static int sum(int a, int b) {
        return a+b;
    }

    private static void updateAValue(int a) {
             a= 1234;
    }

    private static void notifyBookName(Book book) {
        book.setName("Hello");
    }


}
